

import java.util.LinkedList;
import java.util.Scanner;

public class test {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double tmp = ((n / 100.0) / (0.3048 * (1.0 / 12 + 12)));
        if ((tmp*10) - ((int)tmp * 10) > 0.5) {
            System.out.println((((int)(tmp * 10) + 1) * 10 / 12)  + " " + ((int)(tmp * 10) + 1));
        } else {
            System.out.println(((int)(tmp * 10) * 10 / 12) + " " + (int)(tmp * 10));
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int time = scanner.nextInt();
        int minute = scanner.nextInt();
        int n = time;
        int a = 0;
        int count = 0;
        while(n != 0) {
            n /= 10;
            count++;
            if(n < 100 && count == 2) {
                break;
            }
        }
        if(minute < 0) {
            if(n == 0) {
                int q = time + minute;
                if (q >= 0) {
                    System.out.println("0" + q);
                } else {
                    n = 24;
                    while (q < 0) {
                        n--;
                        q += 60;
                    }
                    System.out.println(n * 100 + q);
                }
            }else {
                int p = time - n * 100 + minute;
                while(p < 0) {
                    n--;
                    p += 60;
                    if(n < 0) {
                        System.out.println(0);
                        break;
                    }
                }
                if(n > 0) {
                    System.out.println(n * 100 + p);
                }
            }
        }else {
            int m = time - n * 100 + (minute - ((minute / 60) * 60));
            n = n + minute / 60 + m / 60;
            System.out.println(n * 100 + m % 60);
        }
    }

    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = 0;
        while(n != 0) {
            int a = n % 10;
            sum = sum * 10 + a;
            n /= 10;
        }
        System.out.println(sum);
    }

    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum1 = 0;
        int sum2 = 0;
        while(n != 0) {
            int a = n % 16;
            sum1 = sum1 * 10 + a;
            n /= 16;
        }
        if(sum1 < 16 && sum1 > 10) {
            System.out.println(sum1);
        }else {
            while(sum1 != 0) {
                int b = sum1 % 10;
                sum2 = sum2 * 10 + b;
                sum1 /= 10;
            }
            System.out.println(sum2);
        }

    }

    public static void main5(String[] args) {
        Scanner s = new Scanner(System.in);
        double d1 = s.nextDouble();
        int n = s.nextInt();
        char ch = s.next().charAt(2); //每次只能获取一个
        float d2 = (float)s.nextDouble();
        System.out.printf("%c %d %.2f %.2f", ch, n, d1, d2);
        System.out.println();

    }
    public static void main6(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        if(n <= 60) {
            System.out.println("Speed: " + n + " - OK");
        }else {
            System.out.println("Speed: " + n + " - Speeding");
        }
    }

    public static void main7(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        int C = s.nextInt();
        if(A == B) {
            System.out.println(C);
        }else if(A == C) {
            System.out.println(B);
        }else {
            System.out.println(A);
        }
    }
}
